﻿@model CZTopComputers.Models.CartIndexViewModel

@{
    ViewBag.Title = "CZTopComputers: Your Cart";
}

<h2>Your cart</h2>
<table width="90%" align="center">
    <thead><tr>
        <th align="center"></th>
        <th align="center">Quantity</th>
        <th align="left">Item</th>
        <th align="right">Price</th>
        <th align="right">Subtotal</th>
    </tr></thead>
    <tbody>
        @foreach (var line in Model.Cart.Lines)
        {
            <tr>
                <td align="center">@using (Html.BeginForm("RemoveFromCart", "Cart"))
                                   {
                                    @Html.Hidden("ID", line.Product.ID)
                                    @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
<input type="submit" value="RemoveFromCart" />
                                   }</td>
                <td align="center"><table><tr><td>@using (Html.BeginForm("AddToCart", "Cart"))
                                   {
                                    @Html.Hidden("ID", line.Product.ID)
                                    @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
                                    <input type="submit" value="+" />
                                   }<td /><td>@line.Quantity<td /><td>@using (Html.BeginForm("RemoveOneFromCart", "Cart"))
                                                  {
                                    @Html.Hidden("ID", line.Product.ID)
                                    @Html.Hidden("returnUrl", Request.Url.PathAndQuery)
                                    <input type="submit" value="-" />
                                                  }</td></td><tr /></table></td>
                <td align="left">@line.Product.Name</td>
                <td align="right">@line.Product.Price.ToString("c")</td>
                <td align="right">@((line.Quantity * line.Product.Price).ToString("c"))</td>
            </tr>
        }
    </tbody>
    <tfoot><tr>
        <td colspan="3" align="right">Total:</td>
        <td align="right">
            @Model.Cart.ComputeTotalValue().ToString("c")
        </td>
    </tr></tfoot>
</table>
<p align="center" class="actionButtons">
    <a href="@Model.ReturnUrl">Continue shopping</a>
</p>
